package createthread;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @description:
 * @author: jhy
 * @time: 2021/4/10 21:11
 */
public class CreateThreadDemo4 {

    public static void main(String[] args) {

        //创建一个具有固定线程数的线程池
        ExecutorService threadPool = Executors.newFixedThreadPool(5);

        for(int i = 0;i < 10;i++){
            threadPool.execute(()->{

                System.out.println(Thread.currentThread().getName() + "执行了");
            });
        }

        //关闭线程池
        threadPool.shutdown();
    }
}
